import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import Components from 'unplugin-vue-components/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import AutoImport from "unplugin-auto-import/vite"
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    // 解析单文件组件 插件
    vue(),
    // 自动导入的插件 , 解析器可以是 vant  element  and-vue
    Components({
      //
      dts:false,
      // 关闭 resolver  自动导入 手动处理  Toast  Comfrim
      resolvers: [VantResolver({importStyle:false})]
    }),
    createSvgIconsPlugin({
      // 指定图标素材文件夹 , 绝对路径(path  node包)
      iconDirs:[path.resolve(process.cwd(),'src/icons')]
    }),
    AutoImport({
      imports: ["vue", "vue-router", "pinia", "vue-i18n"],
      dts: "src/auto-imports.d.ts",
      dirs: ["src/composables", "src/stores"],
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
